# -*- coding:utf-8 -*-
from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel
from typing import List, Literal, Optional, Union
from module_admin.annotation.pydantic_annotation import as_query


class DailyModel(BaseModel):
    """
    表对应pydantic模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)
    amount: Optional[float] =  Field(default=None, description='成交额 （千元）')
    change: Optional[float] =  Field(default=None, description='涨跌额')
    close: Optional[float] =  Field(default=None, description='收盘价')
    create_time: Optional[datetime] =  Field(default=None, description='创建时间')
    high: Optional[float] =  Field(default=None, description='最高价')
    id: Optional[int] =  Field(default=None, description='ID')
    low: Optional[float] =  Field(default=None, description='最低价')
    open: Optional[float] =  Field(default=None, description='开盘价')
    pct_chg: Optional[float] =  Field(default=None, description='涨跌幅 【基于除权后的昨收计算的涨跌幅：（今收-除权昨收）/除权昨收 】')
    pre_close: Optional[float] =  Field(default=None, description='昨收价【除权价，前复权】')
    trade_date: Optional[datetime] =  Field(default=None, description='交易日期')
    ts_code: Optional[str] =  Field(default=None, description='股票代码')
    update_time: Optional[datetime] =  Field(default=None, description='更新时间')
    vol: Optional[float] =  Field(default=None, description='成交量 （手）')


@as_query
class DailyPageModel(DailyModel):
    """
    分页查询模型
    """
    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')